package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;


/**
 * Created by windo on 2015/11/24.
 */
public class UpdatePasswordTask extends CouponHttpBaseTask {
    private static final String OLD_PWD = "oldPwd";
    private static final String NEW_PWD = "newPwd";
    //private static final String PWD_AGAIN = "pwdAgain";
    private String mOldPwd;
    private String mNewPwd;
    //private String mPwdAagin;

    public UpdatePasswordTask(String oldpwd, String newpwd) {
        super(TaskType.UPDATE_PASSWORD_TASK);
        mOldPwd = oldpwd;
        mNewPwd = newpwd;
       // mPwdAagin = pwdagain;

    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.UPDATE_PASSWORD_REQUEST);
            JSONObject json = new JSONObject();
            json.put(OLD_PWD, mOldPwd);
            json.put(NEW_PWD, mNewPwd);
           // json.put(PWD_AGAIN, mPwdAagin);
            request.setData(json.toString());
            request.setApiNo(ApiNo.UPDATE_PASSWORD);
            addRequest(request);
        }
    }

}
